package cn.tedu.submarine;

import javax.swing.*;
import java.util.Random;

/*
水雷
 */
public class Mine extends SeaObject {
    public Mine(int x, int y){//水雷坐标不能写死
        super(11,11,x,y,1);
    }

    /*重写Move移动*/
    public void move() {
        Random rand = new Random();
        int type = rand.nextInt(3);
        if (type == 0) {
            y -= speed;
            x -= speed*5;
        } else if (type == 1) {
            y -= speed;
            x -= speed*5;
        } else {
            y -= speed;
            x += speed*10;

        }

    }

    public ImageIcon getImage(){
        return Images.mine;
    }

    /**检测潜艇越界*/
    public boolean isOutofBounds(){
        return y <= 150-height;
    }

    public void shootMine(){

    }
}
